/* Copyright (c) 2010, David Kreuter. See LICENSE for more information */

#ifndef IN_HEADERS_H
#error This file should be included through "headers.h"
#endif

#define WRF(repeat) (1+((repeat)&4)/4)
#define HRF(repeat) (1+((repeat)&8)/8)

typedef struct _rgba{
	uint8 r,g,b,a;
}rgba;

typedef struct _tex_pal{
	char name[17];
	uint32 offset;
	uint32 len;
	uint8  num_colors;
	rgba  *color;
}tex_pal;

typedef struct _tex_tex{ // This is so STUPID!!! Confusion guaranteed!
	char name[17];
	uint32 offset;
	uint32 len;
	uint16 w,h;
	uint8 *data;
	uint8 format;
	uint8 color0;
}tex_tex;

typedef struct _tex{
	uint32 len; // For developing reasons! Delete in stable-version!
	uint32 pal_start; // This one too
	uint8 num_texs;
	uint8 num_pals;
	tex_tex *tex;
	tex_pal *pal;
}tex;

rgba *make_mat(uint8, uint8, uint8, tex*);
tex *read_tex(uint8 *, uint32);
int write_tex(tex *, uint8 *, uint32);
void free_tex(tex *);
uint32 size_tex(tex *);
